#ifndef EMENY_H
#define EMENY_H

#include "player.h"
#include "affiliate/sprite_anim.h"

class Enemy : public Actor
{
protected:
    enum class State{
        NORMAL,
        HURT,
        DIE
    };
    State current_state_ = State::NORMAL;

    Player* target_ = nullptr;
    SpriteAnim* anim_normal_ = nullptr;
    SpriteAnim* anim_hurt_ = nullptr;
    SpriteAnim* anim_die_ = nullptr;
    SpriteAnim* current_anim_ = nullptr;
    int score_ = 10;
public:
    static Enemy* addEnemychild(Object* parent, glm::vec2 pos, Player* target);
    virtual void init() override;
    virtual void update(float dt) override;

    // getter and setters
    Player* getTarget() { return target_; }
    void setTarget(Player* target) { target_ = target; }

private:
    float timer_ = 0;
    void aim_target(Player* target);
    void checkState();
    void changeState(State new_state);
    void attack();
    void remove();
};

#endif // EMENY_H